generating html form on the fly
generating html form on the fly
am 23.10.2007 00:00:13 von ll
I'm currently working with a cgi script which can upload, view, or
delete files in a given directory. The delete section is rather
cumbersome, in that the user has to type in the file name and password
and then hit the delete button.
I've created an html form in the view section that puts checkboxes
next to each file listed. Here's the code I have (below). I'm
getting an error that says that the 'post' command isn't recognized.
Thanks for any help,
Louis
------------------------------------------------
sub listfilenames {
&check_url_referer;
if ($in{'pwd'} ne $superpwd) {
&error_password;
}
if (!$in{'filedirname'}) {
&error_no_upload_directory;
}
$list_dir = "$parent_dir$in{'filedirname'}";
if (opendir(DIR,"$list_dir") == 1) {
@files = readdir(DIR);
closedir(DIR);
}
else {
&error_cannot_open_dir;
}
&set_content_type;
print "
\"FF0000\">Listing of Filenames\n";
print "The following filenames are found in directory
\"$in{'filedirname'}\":
\n";
print "\n";
print "
\n";
print "\n";
&listfilenames_ok;
}
Re: generating html form on the fly
am 23.10.2007 01:01:57 von xhoster
ll wrote:
> I'm currently working with a cgi script which can upload, view, or
> delete files in a given directory. The delete section is rather
> cumbersome, in that the user has to type in the file name and password
> and then hit the delete button.
> I've created an html form in the view section that puts checkboxes
> next to each file listed. Here's the code I have (below). I'm
> getting an error that says that the 'post' command isn't recognized.
Where exactly are you getting this error? The code you posted looks like
it merely creates the form html (poorly). The error sounds like it coming
from something that processes a form submission. But you could try
changing the "post" to a "get" in the "" element.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
Re: generating html form on the fly
am 23.10.2007 01:06:46 von glex_no-spam
ll wrote:
> I'm currently working with a cgi script which can upload, view, or
> delete files in a given directory. The delete section is rather
> cumbersome, in that the user has to type in the file name and password
> and then hit the delete button.
You have to be very careful about this.
> I've created an html form in the view section that puts checkboxes
> next to each file listed. Here's the code I have (below). I'm
> getting an error that says that the 'post' command isn't recognized.
Post a short and complete example that we can run that shows the
error and where it's coming from. This code is quite poor and
shows many problems, none of which have to do with "'post'
command isn't recognized".
> Thanks for any help,
perldoc -f qq
perldoc -q "What's the difference between calling a function as &foo and
foo()"
perldoc CGI
Use a class to help you separate your HTML and your perl.
perldoc HTML::Template
perldoc Template::Toolkit
If neither are on your system, take a look at CPAN: http://search.cpan.org/
Re: generating html form on the fly
am 23.10.2007 03:19:18 von Tad McClellan
ll wrote:
> I'm
> getting an error that says that the 'post' command isn't recognized.
Please do not paraphrase messages.
You should post the exact text of the message.
> &check_url_referer;
You should not call subroutines that way unless you know what
special treatment that way enables, and you really do want
that special treatment.
It is safer to call subroutions this way instead:
check_url_referer();
> if (!$in{'filedirname'}) {
What if the name of the directory should happen to be "0" ?
(your program will call the error routine rather than doing the right thing)
If you want to test that $in{'filedirname'} actually contains the
name of a directory, then test that it actually contains the name
of a directory:
if ( ! -d $in{filedirname} ) {
or
unless ( -d $in{filedirname} ) { # better
> if (opendir(DIR,"$list_dir") == 1) {
perldoc -q vars
Whatâs wrong with always quoting "$vars"?
It is only a happy accident that today's opendir() returns one
on success.
It is specified to return true, and may change to any other true
value at any release, so you should check for truth instead:
if ( opendir DIR, $list_dir ) {
> print "